home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.03 Mar 90 / XCMD Mar Code / •Listing 5•RemoveControl XFCN.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-06  |  1.5 KB  |  65 lines  |  [TEXT/KAHL]

  1. /************************************/
  2. /* File: RemoveControl XFCN.c        */
  3. /*                                     */
  4. /* Parameters:                        */
  5. /* params[0] == control handle        */
  6. /*                                    */
  7. /* If no more control in the list    */
  8. /* go ahead and dispose the patch    */
  9. /*                                    */
  10. /* returns NIL to indicate the         */
  11. /* control was removed                */
  12. /* --------------------------------    */
  13. /* © 1989 Donald Koscheka            */
  14. /* All Rights Reserved                */
  15. /************************************/
  16.  
  17. #define        UsingHypercard
  18.  
  19. #include    <MacTypes.h>
  20. #include    <OSUtil.h>
  21. #include    <ControlMgr.h>
  22. #include     <HyperXCmd.h>
  23. #include    <HyperUtils.h>
  24. #include    "Control XFCN.h"
  25.  
  26. #define        ScrollSize            15
  27. #define        CONTROL_TYPES        6000
  28.  
  29. #include    "miniParser.c"
  30.  
  31. pascal void main( paramPtr )
  32.     XCmdBlockPtr    paramPtr;
  33. {
  34.     ControlHandle    theControl        = NIL;
  35.     WindowPtr        theWindow        = FrontWindow();
  36.     WindowPeek        wPeek            = (WindowPeek)theWindow;
  37.     wdGlobalsHand    windH;
  38.     
  39.     if( paramPtr->params[0] ){
  40.         theControl = (ControlHandle)paramtoNum( paramPtr, 0 );
  41.         
  42.         if( validHandle( theControl ) )
  43.             DisposeControl( theControl );
  44.  
  45.     }/*** if paramPtr[0] ***/
  46.  
  47.     /*** if no more control in the list        ***/
  48.     /*** remove the patch since it isn't    ***/
  49.     /*** needed any longer                    ***/
  50.     if( !wPeek->controlList ){
  51.         if( windH = (wdGlobalsHand)GetSystemResource( CONTROL_INFO, CONTROL_PATCH ) ){
  52.             wdGlobalsPtr    wp         = *windH;
  53.             Handle            patch     = (Handle)(wp->evtProc);
  54.             
  55.             /*** unload the patch    ***/
  56.             NSetTrapAddress( wp->oldTrap, EVENT_TRAP, ToolTrap);
  57.             TrashHandle( patch );
  58.             RemoveSystemResource( (Handle)windH );
  59.         }    
  60.     }
  61.  
  62.     paramPtr->returnValue = NIL;
  63. }
  64.  
  65.